//package com.thinksns.sociax.t4.android.event;
//
//import android.annotation.SuppressLint;
//import android.content.Context;
//import android.content.Intent;
//import android.graphics.Bitmap;
//import android.graphics.Rect;
//import android.media.ThumbnailUtils;
//import android.os.Bundle;
//import android.os.Handler;
//import android.os.Message;
//import android.provider.MediaStore;
//import android.text.TextUtils;
//import android.util.Log;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.view.ViewTreeObserver;
//import android.widget.AdapterView;
//import android.widget.BaseAdapter;
//import android.widget.EditText;
//import android.widget.FrameLayout;
//import android.widget.GridView;
//import android.widget.HorizontalScrollView;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.RelativeLayout;
//import android.widget.Toast;
//
//import com.bumptech.glide.Glide;
//import com.google.gson.Gson;
//import com.google.gson.GsonBuilder;
//import com.thinksns.sociax.android.R;
//import com.thinksns.sociax.component.CustomTitle;
//import com.thinksns.sociax.component.LeftAndRightTitle;
//import com.thinksns.sociax.t4.android.Thinksns;
//import com.thinksns.sociax.t4.android.ThinksnsAbscractActivity;
//import com.thinksns.sociax.t4.android.data.StaticInApp;
//import com.thinksns.sociax.t4.android.image.BitmapFactoryUtils;
//import com.thinksns.sociax.t4.android.img.Bimp;
//import com.thinksns.sociax.t4.android.img.PhotoActivity;
//import com.thinksns.sociax.t4.android.popupwindow.PopupWindowListDialog;
//import com.thinksns.sociax.t4.android.temp.SelectImageListener;
//import com.thinksns.sociax.t4.android.video.ActivityIjkPlayer;
//import com.thinksns.sociax.t4.component.SmallDialog;
//import com.thinksns.sociax.t4.unit.UnitSociax;
//import com.thinksns.sociax.t4.util.LogUtils;
//import com.thinksns.sociax.thinksnsbase.activity.widget.ListFaceView;
//import com.thinksns.sociax.thinksnsbase.network.ApiHttpClient;
//import com.thinksns.sociax.thinksnsbase.utils.FormFile;
//import com.thinksns.sociax.unit.Compress;
//import com.thinksns.sociax.unit.SociaxUIUtils;
//import com.thinksns.tschat.constant.TSConfig;
//
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//
//import me.nereo.multi_image_selector.MultiImageSelectorActivity;
//
///**
// * Created by zhiyicx on 2017/5/9.
// */
//
//public class EventDetailCreateActivity extends ThinksnsAbscractActivity implements View.OnClickListener, View.OnLongClickListener {
//
//    public static final int DETAIL_REQUEST = 1241;
//    private static final int TYPE_PIC = 1002;
//    private static final int TYPE_VIDEO = 1001;
//    private static final int TYPE_NOR = 1000;
//    public static final String DETAIL_BEAN ="detail_bean";
//    private static String staticVideoPath;
//
//    private EditText event_detail_et;
//    private ImageView event_camera_iv;
//    private ImageView event_face_iv;
//    private LinearLayout event_camera_ll;
//    private LinearLayout event_album_ll;
//    private LinearLayout event_video_ll;
//    private ListFaceView face_view;
//    private RelativeLayout event_media_rl;
//    private FrameLayout fl_video_pre;
//    private ImageView iv_video_pre;
//    private GridView noScrollgridview;
//    protected SelectImageListener listener_selectImage;
//    private HorizontalScrollView imageHs;
//    private LinearLayout mLlBottom;
//
//    protected SelectedImgGridAdapter adapter;
//    private File file1;
//    private EventDetailBean bean;
//    private SmallDialog smallDialog;
//
//    protected boolean isOriginal = false;//是否发送原图
//    private int media_type = TYPE_NOR;
//
//    private Handler picHandler = new Handler(){
//        @Override
//        public void handleMessage(Message msg) {
//            super.handleMessage(msg);
//            if(msg.arg1 == 1){
//                FormFile[] formfiles = (FormFile[]) msg.obj;
//                upLoadPics(formfiles);
//            }
//        }
//    };
//
//    @Override
//    public String getTitleCenter() {
//        return "活动详情";
//    }
//
//    @Override
//    protected int getLayoutId() {
//        return R.layout.event_detail_activity;
//    }
//
//    @Override
//    protected CustomTitle setCustomTitle() {
//        title = new LeftAndRightTitle(this, R.drawable.img_back,"保存");
//        return super.setCustomTitle();
//    }
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        initView();
//        initListener();
//        initData();
//    }
//
//    @Override
//    protected void onResume() {
//        super.onResume();
//        SociaxUIUtils.showSoftKeyborad(this,event_detail_et);
//        if(media_type!=TYPE_VIDEO)
//        adapter.update();
//    }
//
//    @Override
//    public void finish() {
//        Log.v("testChannel", "/finish/");
//        Bimp.address.clear();
//        staticVideoPath = "";
//        event_detail_et.clearFocus();
//        UnitSociax.hideSoftKeyboard(this, event_detail_et);
//        super.finish();
//    }
//
//    @Override
//    public View.OnClickListener getRightListener() {
//
//        return new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                if(event_detail_et.getText().toString().equals("")||event_detail_et.getText().toString() == null) {
//                    Toast.makeText(EventDetailCreateActivity.this,"请输入活动详情",Toast.LENGTH_SHORT).show();
//                    return;
//                }
//                smallDialog.show();
//                switch (media_type){
//                    case TYPE_PIC:
//                        LogUtils.logE("upLoadPics");
//                        compressPic();
//                        break;
//                    case TYPE_VIDEO:
//                        LogUtils.logE("upLoadVideo");
//                        upLoadVideo();
//                        break;
//                    case TYPE_NOR:
//                        LogUtils.logE("upLoad");
//                        upLoad();
//                        break;
//               }
//            }
//        };
//    }
//
//
//    @Override
//    public void onClick(View view) {
//        switch (view.getId()){
//            case R.id.event_camera_iv:
//                event_media_rl.setVisibility(View.VISIBLE);
//                face_view.setVisibility(View.GONE);
//                break;
//            case R.id.event_face_iv:
//                event_media_rl.setVisibility(View.GONE);
//                face_view.setVisibility(View.VISIBLE);
//                break;
//            case R.id.event_video_ll:
//                if(media_type == TYPE_PIC) {
//                    Toast.makeText(EventDetailCreateActivity.this, "不能同时上传图片和视频", Toast.LENGTH_SHORT).show();
//                    return;
//                }
//
//                if (staticVideoPath != null && !staticVideoPath.equals("null") && !staticVideoPath.equals("")) {
//                    showSelectVideoPopUpWindow(event_detail_et);
//                } else {
//                    recordVideo();
//                }
//                break;
//            case R.id.event_camera_ll:
//                if(media_type == TYPE_VIDEO) {
//                    Toast.makeText(EventDetailCreateActivity.this, "不能同时上传图片和视频", Toast.LENGTH_SHORT).show();
//                    return;
//                }
//
//                listener_selectImage.cameraImage();
//                break;
//            case R.id.event_album_ll:
//                if(media_type == TYPE_VIDEO) {
//                    Toast.makeText(EventDetailCreateActivity.this, "不能同时上传图片和视频", Toast.LENGTH_SHORT).show();
//                    return;
//                }
//
//                selectPhoto();
//                break;
//            case R.id.fl_video_pre:
//                Intent videoIntent = new Intent(this, ActivityIjkPlayer.class);
//                videoIntent.putExtra("url", staticVideoPath);
//                startActivity(videoIntent);
//                break;
//        }
//    }
//
//    @Override
//    public boolean onLongClick(View view) {
//        switch (view.getId()) {
//            case R.id.fl_video_pre:
//                if (staticVideoPath != null && !staticVideoPath.equals("null") && !staticVideoPath.equals("")) {
//                    showSelectVideoPopUpWindow(event_detail_et);
//                }
//                break;
//        }
//        return false;
//    }
//
//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//        super.onActivityResult(requestCode, resultCode, data);
//        if (resultCode == RESULT_OK) {
//            switch (requestCode) {
//                case DETAIL_REQUEST:
//                    staticVideoPath = data.getStringExtra("video_path");
//                    LogUtils.logE("视频路径" + staticVideoPath);
//                    media_type = TYPE_VIDEO;
//                    resetVideo();
//                    break;
//                case StaticInApp.LOCAL_IMAGE:
//                    List<String> photoList = data.getStringArrayListExtra(MultiImageSelectorActivity.EXTRA_RESULT);
//                    boolean original = data.getBooleanExtra(MultiImageSelectorActivity.EXTRA_SELECT_ORIGIANL, false);
//                    imageHs.setVisibility(View.VISIBLE);
//                    for (String addr : photoList) {
//                        if (Bimp.address.size() == 9)
//                            break;
//                        if (!Bimp.address.contains(addr)) {
//                            Bimp.address.add(addr);
//                            adapter.update();
//                        }
//                    }
//                    isOriginal = original;
//                    media_type = TYPE_PIC;
//                    break;
//                case StaticInApp.CAMERA_IMAGE:
//
//                    String path = listener_selectImage.getImagePath();
//                    if (path != null
//                            && Bimp.address.size() < 9) {
//                        Bimp.address.add(path);
//                        imageHs.setVisibility(View.VISIBLE);
//                    }
//                    media_type = TYPE_PIC;
//                    isOriginal = false;             //默认对拍照的图片压缩
////                    setMedia(HAS_IMAGE);
//                    break;
//            }
//        }
//    }
//
//    private void initView(){
//        event_detail_et = (EditText) findViewById(R.id.event_detail_et);
//        event_camera_iv = (ImageView) findViewById(R.id.event_camera_iv);
//        event_face_iv = (ImageView) findViewById(R.id.event_face_iv);
//        event_camera_ll = (LinearLayout) findViewById(R.id.event_camera_ll);
//        event_album_ll = (LinearLayout) findViewById(R.id.event_album_ll);
//        event_video_ll = (LinearLayout) findViewById(R.id.event_video_ll);
//        event_media_rl = (RelativeLayout) findViewById(R.id.event_media_rl);
//        fl_video_pre = (FrameLayout) findViewById(R.id.fl_video_pre);
//        face_view = (ListFaceView) findViewById(R.id.face_view);
//        iv_video_pre = (ImageView) findViewById(R.id.iv_video_pre);
//        noScrollgridview = (GridView) findViewById(R.id.gv_preview);
//        imageHs = (HorizontalScrollView) findViewById(R.id.imageHoriScroll);
//        face_view.initSmileView(event_detail_et);
//        UnitSociax.hideSoftKeyboard(this, event_detail_et);
//        mLlBottom = (LinearLayout) findViewById(R.id.ll_bottom);
//    }
//
//    private void initListener(){
//        event_camera_iv.setOnClickListener(this);
//        event_face_iv.setOnClickListener(this);
//        event_camera_ll.setOnClickListener(this);
//        event_video_ll.setOnClickListener(this);
//        event_album_ll.setOnClickListener(this);
//        fl_video_pre.setOnClickListener(this);
//        fl_video_pre.setOnLongClickListener(this);
//        onKeyBoardState();
//    }
//
//    private void initData(){
//        if (listener_selectImage == null) {
//            listener_selectImage = new SelectImageListener(this);
//        }
//        smallDialog = new SmallDialog(this,"正在上传");
//        initPicviews();
//
//        Intent intent = getIntent();
//        String detailInfo = intent.getStringExtra(EventDetailCreateActivity.DETAIL_BEAN);
//        if(!TextUtils.isEmpty(detailInfo)){
//            event_detail_et.setText(detailInfo);
//            event_detail_et.setSelection(detailInfo.length());
//        }
//    }
//
//    private void resetVideo() {
//        if (!TextUtils.isEmpty(staticVideoPath)) {
//            iv_video_pre.setImageBitmap(getVideoThumbnail(staticVideoPath, 260, 260,
//                    MediaStore.Images.Thumbnails.FULL_SCREEN_KIND));
//            fl_video_pre.setVisibility(View.VISIBLE);
//        }else{
//            fl_video_pre.setVisibility(View.GONE);
//        }
//    }
//
//    private void unVideo(){
//        media_type = TYPE_NOR;
//        fl_video_pre.setVisibility(View.GONE);
//    }
//
//    private void unPic(){
//        media_type = TYPE_NOR;
//        imageHs.setVisibility(View.GONE);
//    }
//
//    /**
//     * 获取视频的预览图
//     *
//     * @param videoPath
//     * @param width
//     * @param height
//     * @param kind
//     * @return
//     */
//    private Bitmap getVideoThumbnail(String videoPath, int width, int height,
//                                     int kind) {
//        Bitmap bitmap = null;
//        // 获取视频的缩略图
//        bitmap = ThumbnailUtils.createVideoThumbnail(videoPath, kind);
//        bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,
//                ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
//        Date date = new Date();
//        file1 = BitmapFactoryUtils.saveBitmap(this,bitmap, date.getTime()+"", TSConfig.CACHE_PATH);
//        return bitmap;
//    }
//
//    /**
//     * 视频点击图标弹出菜单
//     *
//     * @param v
//     */
//    private void showSelectVideoPopUpWindow(final View v) {
//        final PopupWindowListDialog.Builder builder = new PopupWindowListDialog.Builder(v.getContext());
//        builder.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                if (position == 0) {
//                    // 清除视频
//                    staticVideoPath = "";
//                    UnitSociax.hideSoftKeyboard(EventDetailCreateActivity.this, event_detail_et);
//                    media_type = TYPE_NOR;
//                    resetVideo();
//                } else if (position == 1) {
//                    recordVideo();
//                } else {
//                    builder.dimss();
//                }
//            }
//        });
//
//        List<String> datas = new ArrayList<String>();
//        datas.add("删除");
//        datas.add("重拍");
//        datas.add("取消");
//        builder.create(datas);
//    }
//
//    private void recordVideo() {
//        Intent intent = new Intent(EventDetailCreateActivity.this,EventMediaActivity.class);
//        startActivityForResult(intent,DETAIL_REQUEST);
//    }
//
//    private void selectPhoto() {
//        Intent getImage = new Intent(this, MultiImageSelectorActivity.class);
//        getImage.putExtra(MultiImageSelectorActivity.EXTRA_SELECT_COUNT, 9);
//        getImage.putExtra(MultiImageSelectorActivity.EXTRA_SHOW_CAMERA, false);
//        getImage.putExtra(MultiImageSelectorActivity.EXTRA_SELECT_MODE, MultiImageSelectorActivity.MODE_MULTI);
//        getImage.putStringArrayListExtra(MultiImageSelectorActivity.EXTRA_DEFAULT_SELECTED_LIST,
//                Bimp.address);
//        startActivityForResult(getImage, StaticInApp.LOCAL_IMAGE);
//    }
//
//    private void initPicviews() {
//        adapter = new SelectedImgGridAdapter(this, noScrollgridview);
//        noScrollgridview.setAdapter(adapter);
//        if (media_type == TYPE_PIC) {
//            //刷新照片列表
//            adapter.update();
//        }
//        noScrollgridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//
//            public void onItemClick(AdapterView<?> arg0, View view, int arg2,
//                                    long arg3) {
//                SociaxUIUtils.hideSoftKeyboard(EventDetailCreateActivity.this,
//                        event_detail_et);
//                if (arg2 == Bimp.address.size()) {
//                    //选择图片
//                    SociaxUIUtils.hideSoftKeyboard(getApplicationContext(), event_detail_et);
//                    showSelectImagePopUpWindow(view);
//                } else {
//                    Intent intent = new Intent(EventDetailCreateActivity.this,
//                            PhotoActivity.class);
//                    intent.putExtra("ID", arg2);
//                    //预览选择的照片
//                    startActivityForResult(intent, StaticInApp.UPLOAD_WEIBO);
//                }
//            }
//        });
//
//    }
//
//    private void showSelectImagePopUpWindow(final View v) {
//        final PopupWindowListDialog.Builder builder = new PopupWindowListDialog.Builder(v.getContext());
//        builder.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                if (position == 0) {
//                    selectPhoto();
//                } else if (position == 1) {
//                    listener_selectImage.cameraImage();
//                } else {
//                    builder.dimss();
//                }
//            }
//        });
//
//        List<String> datas = new ArrayList<String>();
//        datas.add("本地图片");
//        datas.add("相机拍照");
//        datas.add("取消");
//        builder.create(datas);
//    }
//
//    public void compressPic(){
//        Thread thread = new Thread(){
//            @Override
//            public void run() {
//                int size = Bimp.address.size();
//                FormFile[] formfiles = new FormFile[size];
//                smallDialog.setTitle("正在压缩");
//
//                for(int i =0 ; i < size; i++){
//                    File file = new File(Bimp.address.get(i));
//                    FormFile formFile = new FormFile(Bimp.getInputStreamFromLocal(Bimp.address.get(i), false),
//                            file.getName(), "pic",
//                            "application/octet-stream");
//                    formfiles[i] = formFile;
//                }
//                Message message = new Message();
//                message.arg1 = 1;
//                message.obj = formfiles;
//                picHandler.sendMessage(message);
//            }
//        };
//        thread.start();
//    }
//
//    public void upLoadPics(FormFile[] formfiles){
//
////        int size = Bimp.address.size();
////        FormFile[] formfiles = new FormFile[size];
////        smallDialog.setTitle("正在压缩");
////
////        for(int i =0 ; i < size; i++){
////            File file = new File(Bimp.address.get(i));
////            FormFile formFile = new FormFile(Bimp.getInputStreamFromLocal(Bimp.address.get(i), false),
////                    file.getName(), "pic",
////                    "application/octet-stream");
////            formfiles[i] = formFile;
////        }
////        Message message = new Message();
////        message.arg1 = 1;
////        message.obj = formfiles;
////        picHandler.sendMessage(message);
//
//        Thinksns.getApplication().getApiEvent().uploadImage(formfiles, new ApiHttpClient.HttpResponseListener() {
//            @Override
//            public void onSuccess(Object result) {
//                smallDialog.dismiss();
//                String json = (String) result;
//                LogUtils.logE("upLoadPics" + json);
//                Gson gson = new Gson();
//                EventPhotosBean eventPhotoBean = gson.fromJson(json,EventPhotosBean.class);
//                String pics = "";
//                for(int i = 0 ; i < eventPhotoBean.getData().size();i++){
//                    pics += eventPhotoBean.getData().get(i).getAttach_id();
//                    if(i!=eventPhotoBean.getData().size()-1){
//                        pics += ",";
//                    }
//                }
//                bean = new EventDetailBean(event_detail_et.getText().toString(),
//                        pics,"");
//                LogUtils.logE("upLoadPics" + bean.toString());
//                Intent intent = new Intent();
//                Bundle bundle = new Bundle();
//                bundle.putSerializable(DETAIL_BEAN,bean);
//                intent.putExtras(bundle);
//                setResult(RESULT_OK,intent);
//                finish();
//            }
//
//            @Override
//            public void onError(Object result) {
//                smallDialog.dismiss();
//                Throwable e = (Throwable) result;
//                LogUtils.logE("upLoadPics" + e.getMessage());
//                Toast.makeText(EventDetailCreateActivity.this,"上传失败",Toast.LENGTH_SHORT).show();
//            }
//        });
//    }
//
//    public void upLoad(){
//        bean = new EventDetailBean(event_detail_et.getText().toString(),"",
//                "");
//        LogUtils.logE("upLoad" + bean.toString());
//        Intent intent = new Intent();
//        Bundle bundle = new Bundle();
//        bundle.putSerializable(DETAIL_BEAN,bean);
//        intent.putExtras(bundle);
//        setResult(RESULT_OK,intent);
//        finish();
//    }
//
//    public void upLoadVideo(){
//        FormFile formFile = null;
//        FormFile videoFile = null;
//        File file2 = new File(staticVideoPath);
//        if (file1 != null) {
//            formFile = new FormFile(Compress.compressPic(file1),
//                    "avatar.png", "pic", "application/octet-stream");
//        }
//        try {
//            videoFile = new FormFile(new FileInputStream(file2),
//                    file2.getName(), "video", "application/octet-stream");
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }
//        Thinksns.getApplication().getApiEvent().upLoadVideo(new FormFile[]{formFile, videoFile}, new ApiHttpClient.HttpResponseListener() {
//            @Override
//            public void onSuccess(Object result) {
//                smallDialog.dismiss();
//                String json = (String) result;
//                LogUtils.logE("upLoadVideo" + json);
//                Gson gson = new GsonBuilder().create();
//                EventVideoBean eventVideoBean = gson.fromJson(json,EventVideoBean.class);
//                LogUtils.logE("upLoadVideo bean : " + eventVideoBean.toString());
//                bean = new EventDetailBean(event_detail_et.getText().toString(),"",
//                        eventVideoBean.getVideo_id()+"");
//                LogUtils.logE("upLoadVideo" + bean.toString());
//                Intent intent = new Intent();
//                Bundle bundle = new Bundle();
//                bundle.putSerializable(DETAIL_BEAN,bean);
//                intent.putExtras(bundle);
//                setResult(RESULT_OK,intent);
//                finish();
//            }
//
//            @Override
//            public void onError(Object result) {
//                smallDialog.dismiss();
//                Throwable e = (Throwable) result;
//                LogUtils.logE("upLoadVideo" + e.getMessage());
//                Toast.makeText(EventDetailCreateActivity.this,"上传失败",Toast.LENGTH_SHORT).show();
//            }
//        });
//    }
//
//    /**
//     * 监听软键盘弹出状态
//     */
//    private void onKeyBoardState() {
//        findViewById(R.id.ll_main_content).getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
//            @Override
//            public void onGlobalLayout() {
//                //判断窗口可见区域大小  
//                Rect r = new Rect();
//                // getWindowVisibleDisplayFrame()会返回窗口的可见区域高度  
//                getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
//                //如果屏幕高度和Window可见区域高度差值大于整个屏幕高度的1/3，则表示软键盘显示中，否则软键盘为隐藏状态。
//                int mScreenHeight = com.thinksns.sociax.thinksnsbase.utils.UnitSociax.getWindowHeight(EventDetailCreateActivity.this);
//                int heightDifference = mScreenHeight - (r.bottom - r.top);
//                boolean isKeyboardShowing = heightDifference > mScreenHeight / 3;
//                if (isKeyboardShowing) {
//                    mLlBottom.animate().translationY(-heightDifference + com.thinksns.sociax.thinksnsbase.utils.UnitSociax.getDecorViewHeight(EventDetailCreateActivity.this)).setDuration(0).start();
//                } else {
//                    mLlBottom.animate().translationY(0).start();
//                }
//            }
//        });
//    }
//
//    /**
//     * 图片加载
//     */
//
//    @SuppressLint("HandlerLeak")
//    public class SelectedImgGridAdapter extends BaseAdapter {
//        private LayoutInflater inflater;        // 视图容器
//        private Context mContext;
//        private int selectedPosition = -1;      // 选中的位置
//        private boolean shape;
//        private GridView mgridViwew;
//
//        private int imgWidth = 0;   //图片显示宽高
//        private int horizontalSpacing;  //图片左右间隙
//        private int gridViewHeight;     //列表高度
//
//        public boolean isShape() {
//            return shape;
//        }
//
//        public void setShape(boolean shape) {
//            this.shape = shape;
//        }
//
//        public SelectedImgGridAdapter(Context context, GridView gridView) {
//            inflater = LayoutInflater.from(context);
//            this.mContext = context;
//            this.mgridViwew = gridView;
//            imgWidth = UnitSociax.dip2px(context, 68);
//            horizontalSpacing = UnitSociax.dip2px(context, 3);
//            gridViewHeight = UnitSociax.dip2px(context, 70);
//
//        }
//
//        public int getCount() {
//            int count = 0;
//            if (Bimp.address.size() == 0) {
//                count = 1;
//            } else if (Bimp.address.size() == 9)
//                count = 9;
//            else {
//                count = (Bimp.address.size() + 1);
//            }
//
//            //计算列表的宽度
//            int gridviewWidth = count * imgWidth + (count - 1) * horizontalSpacing;
//            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
//                    gridviewWidth, gridViewHeight);
//            mgridViwew.setLayoutParams(params);         // 重点
//            mgridViwew.setNumColumns(count);
//
//            return count;
//        }
//
//        public Object getItem(int arg0) {
//            return null;
//        }
//
//        public long getItemId(int arg0) {
//            return 0;
//        }
//
//        /**
//         * ListView Item设置
//         */
//        public View getView(int position, View convertView, ViewGroup parent) {
//            final int coord = position;
//            ViewHolder holder = null;
//            if (convertView == null) {
//                convertView = inflater.inflate(R.layout.item_published_grida, parent, false);
//                holder = new ViewHolder();
//                holder.image = (ImageView) convertView.findViewById(R.id.item_grida_image);
//                convertView.setTag(holder);
//            } else {
//                holder = (ViewHolder) convertView.getTag();
//            }
//
//            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(imgWidth, imgWidth);
//            holder.image.setLayoutParams(params);
//
//            if (position == Bimp.address.size()) {
////                holder.image.setImageBitmap(BitmapFactory.decodeResource(
////                        getResources(), R.drawable.icon_addpic_unfocused));
//                holder.image.setImageResource(R.drawable.icon_addpic_unfocused);
//            } else {
////                holder.image.setImageBitmap(Bimp.bmp.get(position));
//                Glide.with(mContext)
//                        .load(Bimp.address.get(position))
//                        .into(holder.image);
//            }
//
//            return convertView;
//        }
//
//        public void clearBtm() {
//            Bimp.bmp.clear();
//            adapter.notifyDataSetChanged();
//        }
//
//        public void update(){
//            loading();
//        }
//
//        public void loading() {
//            if (Bimp.address.size() == 0) {
//                imageHs.setVisibility(View.GONE);
//                media_type = TYPE_NOR;
//            } else {
//                imageHs.setVisibility(View.VISIBLE);
//                adapter.notifyDataSetChanged();
//            }
//        }
//
//        public class ViewHolder {
//            public ImageView image;
//        }
//
//    }
//}
